<template>
  <div class="home">
   home
    <button @click="handleClick">{{city}}</button>
  </div>
</template>
<script>
let axios = require('axios');
let jsonpAdapter = require('axios-jsonp');
export default {
  data() {
    return {
      city:"花山"
    }
  },
  methods: {
    handleClick(){
      this.$router.push('/city')
    }
  },
  mounted() {
    var city = localStorage.getItem('city');
    console.log(city);
    if(city){
      this.city = city;
    }
    axios({
      url:"https://apis.map.qq.com/ws/location/v1/ip",
      adapter: jsonpAdapter,
      // ?后的数据 可放在 params里
      params:{
        key:'AH4BZ-WJNWW-452RM-OYKJU-ADB3S-T6BLJ',
        output:'jsonp'
      }
    }).then(res=>{
      console.log(res);
    })
  },
}
</script>